/***2024-12-31 迷途小羔羊
* 用于编写弹道追踪目标的行为
*/
namespace ghost
{
    export class B_Target extends BehaviorBase
    {
		private _checkInterval:number;
		private _lastCheckTime:number;
        constructor(ai:AIBase)
        {
            super(ai);
            let s = this;
            s._checkInterval = CommonUtil.delta * 2;
        }
        public exc(t:number):void
		{
            super.exc(t);
			let s= this;	
            let r:DriftObj = <DriftObj>s._role;		
			if(r._isAOE || r.isDel())
				return;			
			if(t - s._lastCheckTime < s._checkInterval)return;
			if(r._targetMove)
			{
				//子弹飞行中，跟踪弹会在目标偏离范围内实时校准轨迹
				if((r._ballisticType == BallisticType.FOLLOW_OBLIQUE || r._ballisticType == BallisticType.FOLLOW) && r.targetIsValid())
				{
					let posDeviation:boolean;					
					posDeviation = Math.abs(r._targetRoles[0].absX - r._attackTarX) > 6 || Math.abs(r._targetRoles[0].absY - r._attackTarY) > 6;					
					if(posDeviation)
					{			
						s._lastCheckTime = t;			
						r.resetTargetPos(true);
						r.moveTo(r._flyToX, r._flyToY, null, null, r.sts, r._flyUseTime, -1, r._flyToH);
					}
				}
			}
			else
			{					
				r.moveTo(r._flyToX, r._flyToY, null, null, r.sts, r._flyUseTime, -1, r._flyToH);
			}	
			
			if(r._shootH > 0)
			{				
				let per:number = r._flyPercent + (1-r._flyPercent)*r.moveTimeTicker.getPercent();							
				r.absZ = 4 * r._shootH * per * (1 - per);
				if(r._floatH < 0)
					r._floatH = 0;				
			}			
		}
    }
    
}